#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
/*
Copyright (C) 2013 Johan Ceuppens

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#import "FunctorCl.h"

@implementation FunctorX

- (id) init:(void*)f
{
	funptr = f;
	return self;
}

- (void*)dof
{
	return ((*funptr)(nil,nil,nil,nil,nil,nil,nil));
}	

- (void*)dof:(void*)arg0
{
	return ((*funptr)(arg0,nil,nil,nil,nil,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1;
{
	return ((*funptr)(arg0,arg1,nil,nil,nil,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2;
{
	return ((*funptr)(arg0,arg1,arg2,nil,nil,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3;
{
	return ((*funptr)(arg0,arg1,arg2,arg3,nil,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4;
{
	return ((*funptr)(arg0,arg1,arg2,arg3,arg4,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5;
{
	return ((*funptr)(arg0,arg1,arg2,arg3,arg4,nil,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5 arg6:(void*)arg6;
{
	return ((*funptr)(arg0,arg1,arg2,arg3,arg4,arg5,nil));
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1 arg2:(void*)arg2 arg3:(void*)arg3 arg4:(void*)arg4 arg5:(void*)arg5 arg6:(void*)arg6 arg7:(void*)arg7;
{
	return ((*funptr)(arg0,arg1,arg2,arg3,arg4,arg5,arg6));
}

@end
@implementation FunctorY
- (id) init
{
	args = [NSMutableArray new];
	returnType = nil;

	return self;
}

- (SIGCMReturnType*)dof:(NSMutableArray*)array
{
	args = array;
	//apply
	return nil;//FIXME
}

@end

@implementation Functor0

- (id) init:(void*)f
{
	funptr = f;
	return self;
}

- (void*)dof
{
	return (*funptr)();
}

- (Functor*)createManipulator
{
	return ((id)[Functor0 alloc]); //[[Functor0 alloc] init: self] //multiple inheritance self
}

@end

@implementation Functor1

- (id) init:(void*)f
{
	funptr = f;
	return self;
}

- (void*)dof:(void*)arg0
{
	return (*funptr)(arg0);
}

- (Functor*)createManipulator
{
	return ((id)[Functor1 alloc]); //[[Functor0 alloc] init: self] //multiple inheritance self
}

@end

@implementation Functor2

- (id) init:(void*)f
{
	funptr = f;
	return self;
}

- (void*)dof:(void*)arg0 arg1:(void*)arg1
{
	return (*funptr)(arg0,arg1);
}

- (Functor*)createManipulator
{
	return ((id)[Functor2 alloc]); //[[Functor0 alloc] init: self] //multiple inheritance self
}

@end


